#ifndef _BIO_CPP_PARSEERROR_H
#define _BIO_CPP_PARSEERROR_H
#include <string>
#include "ultoa.h"
#include <vector>
#include <exception>
namespace BioCPP
{
    struct bcpp_parse_format_error: public std::exception
    {
        bcpp_parse_format_error() {}
        ~bcpp_parse_format_error()  throw () {}
        void set_data(std::vector<std::string>& preamble_, 
                                         const std::string& matching_format_line_,
                                         unsigned line_cnt_)
        { std::swap(preamble,preamble_) ; 
            matching_format_line = matching_format_line_;  
            line_cnt = line_cnt_;
            message_string = "Data appears to be in " + format_name() + " format.\n"
                          "line #" + ultoa(line_cnt) + ": [" + matching_format_line + "]";
                }
        virtual void throw_error(){ throw *this;}
        std::vector<std::string> preamble;
        std::string matching_format_line;
        std::string message_string;

        unsigned line_cnt;
        virtual std::string format_name() const { return "an unknown format";}
        virtual const char * what () const throw ()
        {
            return message_string.c_str();
        }
        
    };

    class clustal_format_error: public bcpp_parse_format_error
    {    
        virtual std::string format_name() const { return "clustalw";}
        virtual const char * what () const throw ()
        {
            return "clustalw";
        }
        virtual void throw_error(){ throw *this;}
    };
    class phylip_format_error: public bcpp_parse_format_error
    {    
        virtual std::string format_name() const { return "phylip (e.g. paml)";}
        virtual const char * what () const throw ()
        {
            return "phylip";
        }
        virtual void throw_error(){ throw *this;}
    };
}
#endif
